package U;

import rx.Observable;
import rx.Subscriber;

import java.util.Arrays;
import java.util.List;

public class Utils {

    public static final List<Long> LONGS = Arrays.asList(200L, 103L, 1000L, 98627L, 780L);
    public static final List<Integer> INTS = Arrays.asList(1, 3, 12, 102, 110, 745, 6258, 31478, 8627);
    public static final List<String> STRINGS = Arrays.asList("Rex", "Remix", "Blue", "Rap", "Hip-Hop", "Classic");

    public static void main(String[] args) {
        Observable<Integer> observable = Observable.create(new Observable.OnSubscribe<Integer>() {
            public void call(Subscriber<? super Integer> subscriber) {
                for (int i = 0; i < 3; i++) {
                    if (i == 1) {
                        subscriber.onCompleted();
                        System.out.println("hi!");
                    } else {
                        subscriber.onNext(i);
                        System.out.println("hiiiiii");
                    }

                }
            }
        });
        Subscriber<Integer> subscriber = new Subscriber<Integer>() {
            public void onCompleted() {
                System.out.println("onComplete");
            }

            public void onError(Throwable e) {

            }

            public void onNext(Integer integer) {
                System.out.println(integer);
            }
        };
        observable.subscribe(subscriber);
    }

    public static void sleep(long milliseconds){
        try{
            Thread.sleep(milliseconds);
        }catch (InterruptedException e){
            e.printStackTrace();
        }
    }
}
